package com.ashen.boot.admin.configuration.datafilter;

import lombok.Data;

import java.util.Set;

@Data
public class DataFilterMetaData {
    public final Long deptId;
    public final Set<Long> deptIds;
    public final Long userId;
    public final DataFilterTypeEnum filterType;
    public final String sql;

    private DataFilterMetaData(DataFilterMetaData.Builder builder) {
        this.deptId = builder.deptId;
        this.deptIds = builder.deptIds;
        this.userId = builder.userId;
        this.filterType = builder.filterType;
        this.sql = builder.sql;
    }

    public static Builder builder() {
        return new Builder();
    }


    public static class Builder {
        //必须参数
        private Long userId;
        private DataFilterTypeEnum filterType;

        // 可选参数
        private Long deptId;
        private Set<Long> deptIds;
        private String sql;


        public Builder() {
        }

        //使用设置好的参数值新建 OperateLog 对象
        public DataFilterMetaData build(){
            return new DataFilterMetaData(this);
        }


        // 每个 setter 方法都返回当前的对象，做到链式调用
        public DataFilterMetaData.Builder userId(Long deptId) {
            this.userId = userId;
            return this;
        }

        public DataFilterMetaData.Builder deptId(Long deptId) {
            this.deptId = deptId;
            return this;
        }

        public DataFilterMetaData.Builder deptIds(Set<Long> deptIds) {
            this.deptIds = deptIds;
            return this;
        }

        public DataFilterMetaData.Builder filterType(DataFilterTypeEnum filterType) {
            this.filterType = filterType;
            return this;
        }

    }

}
